package cn.glc.daily.life.web.convert;

import cn.glc.daily.life.infrastructure.po.UserAuthsPo;
import cn.glc.daily.life.model.dto.UserSignupDto;
import cn.simon.free.tools.utils.DateUtils;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * 用户登录授权转换类
 *
 * @author simon
 * @date 2020/9/24 15:29
 * @copyright:
 * @modifier
 * @motto a no talent, people who have to study hard
 */
@Mapper
public interface UserAuthsConvert {
    UserAuthsConvert INSTANCE = Mappers.getMapper(UserAuthsConvert.class);

    /**
     * 注册用户转授权用户对象
     *
     * @param userSignupDto
     * @param uid
     * @return
     */
    default UserAuthsPo userSignupDtoToUserAuths(UserSignupDto userSignupDto, long uid) {
        UserAuthsPo userAuthsPo = new UserAuthsPo();
        userAuthsPo.setUid(uid);
        userAuthsPo.setIdentify(userSignupDto.getIdentify());
        userAuthsPo.setCredential(userSignupDto.getCredential());
        userAuthsPo.setType(userSignupDto.getType());
        userAuthsPo.setCreateTime(DateUtils.now());
        userAuthsPo.setDisable(false);
        return userAuthsPo;
    }
}
